package com.aide.simplification.popedom.taglib;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import com.aide.simplification.popedom.popedom.User;

public class GetDeptJSON extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public GetDeptJSON() {
		super();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html; charset=GBK");
		response.setCharacterEncoding("GBK");
		PrintWriter out = response.getWriter();

//		ApplicationContext ctx = WebApplicationContextUtils
//				.getWebApplicationContext(this.getServletContext());
//		User user = (User) ctx.getBean("User");
		User user = new User();
		String useruuid = "";
		if (request.getParameter("useruuid") != null) {
			useruuid = request.getParameter("useruuid");
		}
		List<Map<String, Object>> list = user.findByUserUUIDIsUseInfo(useruuid);
		if (list != null) {
			JSONArray json = JSONArray.fromObject(list);
			out.println(json.toString());
		} else {
			out.println("[]");
		}
		out.flush();
		out.close();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doGet(request, response);
	}

}
